package com.alpha.processor.util;

public class ParseNameUtil {

    public static String fromViewName(String viewName){
        StringBuilder nameBuilder = new StringBuilder();
        String[] nameArray = viewName.split("_");
        for (int i = 0;i<nameArray.length;i++){
            String namePiece = nameArray[i];
            if (i == 0){
                nameBuilder.append(namePiece);
                continue;
            }
            if (namePiece != null && namePiece.length() > 0){
                Character startChar = namePiece.charAt(0);
                Character transStartChar = Character.toUpperCase(startChar);
                String result = namePiece.replaceFirst(startChar.toString(),transStartChar.toString());
                nameBuilder.append(result);
            }
        }
        return nameBuilder.toString();
    }

    public static String fromLayoutName(String viewName){
        StringBuilder nameBuilder = new StringBuilder();
        String[] nameArray = viewName.split("_");
        for (int i = 0;i<nameArray.length;i++){
            String namePiece = nameArray[i];
            if (namePiece != null && namePiece.length() > 0){
                Character startChar = namePiece.charAt(0);
                Character transStartChar = Character.toUpperCase(startChar);
                String result = namePiece.replaceFirst(startChar.toString(),transStartChar.toString());
                nameBuilder.append(result);
            }
        }
        nameBuilder.append("Binding");
        return nameBuilder.toString();
    }
}
